# -*- coding: utf-8 -*-

import sys
import os
import time
import pygame
import actor.hero as hero
import scene.castle as castle
import tools.game_const as game_const
class MyHeroGame:
    '''
    我的英雄游戏
    '''
    def __init__(self):
        '''
        游戏初始化
        :return:
        '''
        pygame.init()
        pygame.display.set_caption('英雄传奇')
        self.show_screen = pygame.display.set_mode((game_const.display_width, game_const.display_height))

        self.myHero = hero.Hero(0, 0)
        self.myHero.init_self()
        self.castle = castle.Castle(self.myHero)
        self.castle.init_self()
    def gameLoop(self):
        '''
        游戏主循环
        :return:
        '''
        clock = pygame.time.Clock()
        self.game_exit = False
        while not self.game_exit:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    game_exit = True
            keys = pygame.key.get_pressed()
            self.myHero.action(keys, None)
            self.castle.update(keys, None)
            self.myHero.update()
            self.castle.draw_all_object(self.show_screen)
            pygame.display.update()
            clock.tick(10)
    def closeGame(self):
        pygame.quit()


#开始游戏
game = MyHeroGame()
game.gameLoop()
game.closeGame()
quit()

